<?php

namespace App\Model\Task;

use App\Model\Model;
use Hyperf\Database\Model\SoftDeletes;

/**
 * @property integer $id
 * @property string $title
 * @property text $content
 * @property integer $create_time
 * @property integer $delete_time
 * @property integer $update_time
 */
class TaskHelp extends Model
{
    use SoftDeletes;

    /**
     * The table associated with the model.
     * 
     * @var string
     */
    protected $table = 'task_help';

    protected $appends = [
      'create_time_format'
    ];

    protected $fillable = [
        'title',
        'content',
        'task_help_category_id',
        'create_time',
        'delete_time',
        'update_time',
    ];

    public function getCreateTimeFormatAttribute($value){
        return $this->checkAttributes('create_time', function($value){
           return date('Y-m-d H:i:s',$value);
        });
    }

    public function TaskHelpCategory(){
        return $this->hasOne(TaskHelpCategory::class,'id','task_help_category_id');
    }
}
